package com.zack.hanNota;

/**
 * @author zack
 * @create 2019-08-02-10:44
 */
public class HanNota {
    private int i=1;//测试步数
    public void hanNota(int n, char from, char dependOn, char to) {

/**
 * 如果只有一个盘子那就直接移掉,不需要中间物
 */
        if (n == 1) {
            move(1, from, to);
        } else {
            hanNota(n - 1, from, to, dependOn);
            move(n, from, to);
            hanNota(n - 1, dependOn, from, to);
        }
    }

    /**
     * 直接打印盘子移动信息
     *
     * @param i
     * @param from
     * @param to
     */
    private void move(int n, char from, char to) {

        System.out.println("第" + i++ + "步从" + from + "-------------->" + to);
    }

    public static void main(String[] args) {
        HanNota hanNota = new HanNota();
        hanNota.hanNota(2, 'X', 'Y', 'Z');
    }
}
